import scipy.stats as ss
from matplotlib.animation import FuncAnimation
import numpy as np
import matplotlib.pyplot as ppl

class UpdateDist(object):
    def __init__(self, ax, resultados):
        self.line, = ax.plot([], [], 'ro')
        self.ax = ax
        self.resultados = resultados

        # Set up plot parameters
        self.ax.set_xlim(0,1.1)
#        self.ax.set_xlim(0, 35)
        self.ax.set_ylim(0, 4)
#        self.ax.set_ylim(0, 8)
#        self.ax.set_ylim(0, 200)
        self.ax.grid(True)

    def init(self):
        self.line.set_data([], [])
        return self.line,

    def __call__(self, i):
        # This way the plot can continuously run and we just keep
        # watching new realizations of the process
        if i == 0:
            return self.init()

        self.line.set_data([res.f1 for res in self.resultados[i]], [res.f2 for res in self.resultados[i]])
        return self.line,

#--------------------------------------------------------
def GO(resultados):
  fig = ppl.figure()
  ax = fig.add_subplot(1, 1, 1)
  ud = UpdateDist(ax, resultados)
  anim = FuncAnimation(fig, ud, frames=np.arange(len(resultados)-1), init_func=ud.init,
          interval=500, blit=True)
  ppl.show()

